data = data3d('../data/head.npz', 'short')
opacity = float_param(0.1, 0.01, 1, 'O')


# center
cx = float_param(0, -1, 1, 'A')
cy = float_param(0, -1, 1, 'B')
cz = float_param(0, -1, 1, 'C')

# radii
rx = float_param(1, 0, 2, 'D')
ry = float_param(1, 0, 2, 'E')
rz = float_param(1, 0, 2, 'F')


# ellipsoid definition
def cut(pos, center, radius):
    x = (pos - center) / radius
    return 1 - dot(x, x)
    

# RGBA computation
center = float3(cx, cy, cz)
radius = float3(rx, ry, rz)
if cut(X, center, radius) < 0: return 0
density = linear_query_3d(data, X) * 32768
if density < -400: return 0
value = (density + 400) / 800
return float4(value, value, value, opacity)

